<script type="text/javascript">
    $(function(){
        $("a.seek-first").button({
            text: false,
            icons: {
                primary: "ui-icon-seek-first"
            }
        });
        
        $("a.seek-prev").button({
            text: false,
            icons: {
                primary: "ui-icon-seek-prev"
            }
        });
        
        $("a.seek-last").button({
            text: false,
            icons: {
                primary: "ui-icon-seek-end"
            }
        });
        
        $("a.seek-next").button({
            text: false,
            icons: {
                primary: "ui-icon-seek-next"
            }
        });
        $("a.show-icon-only").button({
            text: false,
            icons: {
                primary: "ui-icon-search"
            }
        });
        $("a.edit-icon-only").button({
            text: false,
            icons: {
                primary: "ui-icon-pencil"
            }
        });
        $("#list-table").tablesorter({
            headers: {
                3: { 
                    sorter: false 
                }
            } 
        });
    })
</script>
<div id="list" class="span-24">
    <table id="list-table" class="tablesorter">
        <thead>
            <tr>
                <th>Nombre</th>
                <th>Descripción</th>
                <th>Activo</th>
                <th>Acciones</th>
            </tr>
        </thead>
        <tbody>
            <?php foreach ($pager->getResults() as $candidate): ?>
                <tr>
                    <td class="span-5"><a href="<?php echo url_for('candidate_show', $candidate) ?>"><?php echo $candidate->getName() ?></a></td>
                    <td class="span-15"><?php echo $candidate->getDescription() ?></td>
                    <td class="span-1"><?php echo $candidate->getActive() ? 
                            '<span class="ui-icon ui-icon-check"></span>' : '<span class="ui-icon ui-icon-closethick"></span>' ?></td>
                    <td class="span-3 last"> 
                        <a class="show-icon-only" href="<?php echo url_for('candidate_show', $candidate) ?>"><?php echo $candidate->getName() ?></a>
                        <a class="edit-icon-only" href="<?php echo url_for('candidate_edit', $candidate) ?>"><?php echo $candidate->getName() ?></a>
                    </td>
                </tr>
            <?php endforeach; ?>
        </tbody>
    </table>

    <?php if ($pager->haveToPaginate()): ?>
        <div class="pagination span-24 append-bottom">
            <a class="seek-first" href="<?php echo url_for('candidate').'?page=1'.(isset($query) ? '&query='.$query : '') ?>">First</a>
            <a class="seek-prev" 
               href="<?php echo url_for('candidate').'?page='.$pager->getPreviousPage().(isset($query) ? '&query='.$query : '') ?>">Prev</a>

            <?php foreach ($pager->getLinks() as $page): ?>
                <strong>
                    <?php if ($page == $pager->getPage()): ?>
                        <?php echo $page ?>
                    <?php else: ?>
                        <a href="<?php echo url_for('candidate').'?page='.$page.(isset($query) ? '&query='.$query : '') ?>"><?php echo $page ?></a>
                    <?php endif; ?>
                </strong>
            <?php endforeach; ?>

            <a class="seek-next" 
               href="<?php echo url_for('candidate').'?page='.$pager->getNextPage().(isset($query) ? '&query='.$query : '') ?>">Next</a>

            <a class="seek-last" 
               href="<?php echo url_for('candidate').'?page='.$pager->getLastPage().(isset($query) ? '&query='.$query : '') ?>">Last</a>
        </div>
    <?php endif; ?>

    <div class="pagination_desc span-24 append-bottom">
        Total de candidatos: <strong><?php echo count($pager) ?></strong>
        <?php if ($pager->haveToPaginate()): ?>
            - página <strong><?php echo $pager->getPage() ?>/<?php echo $pager->getLastPage() ?></strong>
        <?php endif; ?>
    </div>
</div>